//
//  ThreeViewController.m
//  导航控制器
//
//  Created by apple on 15/9/16.
//  Copyright (c) 2015年 戴维营. All rights reserved.
//

#import "ThreeViewController.h"

@interface ThreeViewController ()

@end

@implementation ThreeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
   
    self.view.backgroundColor = [UIColor brownColor];
    
    //返回上一层；
    UIButton *but = [[UIButton alloc] initWithFrame:CGRectMake(60, 250, 200, 70)];
    
    [but setTitle:@"返回上一个页面" forState:UIControlStateNormal];
    
    [but addTarget:self action:@selector(didD:) forControlEvents:UIControlEventTouchUpInside];
    
    [self.view addSubview:but];
    

}

- (void)didD:(UIButton *)sender
{
//    [self.navigationController popViewControllerAnimated:YES];
    
//  将所有页面控制器都清除了
//    self.navigationController.viewControllers = nil;
    
    NSArray *array = self.navigationController.viewControllers;
    
    NSArray *nArray = @[array[1]];
    
    [self.navigationController setViewControllers:nArray animated:YES];


}


- (void)dealloc
{
    NSLog(@"%s",__func__);
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
